#version 460
#extension GL_GOOGLE_include_directive : enable
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require


#include "../../../../core/shader_binding_ID.h"
//#include "../../../../core/shader_mesh.h"


layout(points) in;
layout(line_strip, max_vertices=24) out;
//layout(triangle_strip, max_vertices=6) out;
//layout(input_primitive) in;


layout(location = 0) in vec4 vColor[];
layout(location = 1) in uint vPrimitiveID[];
layout(location = 2) in vec3 vMinimum[];
layout(location = 3) in vec3 vMaximum[];

layout(location = DEF_BINDING_LocationBindID_RotMat) in mat4 vTranformMat[];

layout(location = 0) out vec4 outColor;
out gl_PerVertex {
	vec4	gl_Position;
};


void main(void){
	//----------------------------- x -------------------------------
	//-x -y -z  +x
	vec3 point = vMinimum[0];
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();

	point.x = vMaximum[0].x;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	EndPrimitive();

	//-x y -z  +x
	point = vMinimum[0];
	point.y = vMaximum[0].y;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();

	point.x = vMaximum[0].x;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	EndPrimitive();


	//-x -y z  +x
	point = vMinimum[0];
	point.z = vMaximum[0].z;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();

	point.x = vMaximum[0].x;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	EndPrimitive();

	//-x y z  +x
	point = vMinimum[0];
	point.yz = vMaximum[0].yz;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();

	point.x = vMaximum[0].x;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	EndPrimitive();





	//----------------------------- z -------------------------------
	//-x -y -z  +z
	point = vMinimum[0];
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	
	point.z = vMaximum[0].z;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	EndPrimitive();

	//x -y -z  +z
	point = vMinimum[0];
	point.x = vMaximum[0].x;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	
	point.z = vMaximum[0].z;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	EndPrimitive();



	//-x y -z  +z
	point = vMinimum[0];
	point.y = vMaximum[0].y;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	
	point.z = vMaximum[0].z;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	EndPrimitive();


	//x y -z  +z
	point = vMinimum[0];
	point.xy = vMaximum[0].xy;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	
	point.z = vMaximum[0].z;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	EndPrimitive();




	//----------------------------- y -------------------------------
	//-x -y -z  +y
	point = vMinimum[0];
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	
	point.y = vMaximum[0].y;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	EndPrimitive();


	//-x -y z  +y
	point = vMinimum[0];
	point.z = vMaximum[0].z;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	
	point.y = vMaximum[0].y;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	EndPrimitive();



	//x -y z  +y
	point = vMinimum[0];
	point.x = vMaximum[0].x;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	
	point.y = vMaximum[0].y;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	EndPrimitive();


	//x -y z  +y
	point = vMinimum[0];
	point.xz = vMaximum[0].xz;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	
	point.y = vMaximum[0].y;
	gl_Position = vTranformMat[0] * vec4(point, 1);
	outColor = vColor[0];
	EmitVertex();
	EndPrimitive();


	return;
}


